<?php

	function generate_name($student_id,$student_name)
	{
		if(empty($student_name)||$student_name==NULL||$student_name=="") 
		{
			$student_name = "未知";	
		}
		return $student_name.'(D-'.sprintf('%06d',$student_id).')';
	}

	function generate_trade_wish($trade_wish)
	{	
		if($trade_wish)
		{
			$wish = config_item('comm.trade_wish');
			return $wish[$trade_wish];
		}
		return NULL;
	}

	function generate_track_result($track_result)
	{
		if($track_result)
		{
			$track_results = config_item('comm.track_result');

			return $track_results[$track_result];
		}
		return NULL;
	}


	function generate_datetime($time)
	{
		if($time)
		{
			return date('Y-m-d H:i:s',$time);
		}
		return NULL;
	}

	function generate_actions($track_id,$student_id)
	{
		$html = '<a href="'.site_url('/sale/track_edit/'.$track_id).'" class="btn btn-xs btn-default">编辑</a> ';
								
		$html .= '<button class="btn btn-xs btn-success clue_track_btn" data-target="#track_modal" data-toggle="modal" data-pk="'.$student_id.'">追踪</button> ';
		
		if(has_permission('sale/tracks','track_del'))
		{
			$html .= '<button data-pk="'.$track_id.'" class="btn btn-xs btn-danger track_del_btn">删除</button>';
		}

		return $html;
	}